<template>
	<view class="content">
		<view class="order_box">
			<view class="express_code">
				运单号：{{detail_data.express_code}}
			</view>
			<view class="receiver_base_msg_box">
				<img src="../../static/image/list_icon_shoujian@2x.png" alt="">
				<text class="receiver_name">{{detail_data.receiver_name}}</text>
				<text class="receiver_phone">{{detail_data.receiver_phone}}</text>
			</view>
			<view class="receiver_address">
				{{detail_data.receiver_province_text + detail_data.receiver_city_text + detail_data.receiver_district_text + detail_data.receiver_address}}
			</view>
			<view class="fenge" v-if="detail_data.receiver_remark != ''"></view>
			<view class="receiver_remark" v-if="detail_data.receiver_remark != ''">
				<view>备注：</view>
				<view>{{detail_data.receiver_remark}}</view>
			</view>
			<view class="fenge" v-if="detail_data.agent_fee != '0.00元（大写：零元整）'"></view>
			<view class="agent_fee" v-if="detail_data.agent_fee != '0.00元（大写：零元整）'">
				<view>代收货款：</view>
				<view class="agent_fee_text">{{detail_data.agent_fee_text}}</view>
			</view>
		</view>
		<view class="collect_btn" @click="collect">揽收</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				token: '',
				log_state: false,
				search_input: '',
				code: '',
				detail_data: {
					express_code: '-',
					receiver_name: '-',
					receiver_phone: '-',
					receiver_province_text: '-',
					receiver_city_text: '-',
					receiver_district_text: '-',
					receiver_address: '-'
				},
			}
		},
		onLoad(options) {
			uni.getStorage({
				key: 'token',
				success: res => {
					this.token = res.data
					this.code = options.code
					this.get_order_detail(res.data,options.code)
				}
			})
		},
		methods: {
			search(e) {
				if ((e.detail.value.search_input == '') || (e.detail.value.search_input == ' ')) {
					return false
				}
				this.search_input = e.detail.value.search_input
				// 跳转搜索扫码结果页面
			},
			get_order_detail (token,code) {
				this.$https.get (`api/mini_collection/v1/orders/detail?token=${token}&express_code=${code}`)
				.then(res => {
					console.log(res)
					this.detail_data = res.data
				})
			},
			collect () {
				this.$https.post(`api/mini_collection/v1/orders/collect`,{
					token: this.token,
					express_code: this.code
				})
				.then(res => {
					console.log(res)
					if (res.data && (res.data.result === 'OK')){
						uni.showToast({
							title: '揽收成功',
							mask: true
						})
						setTimeout(() => {
							uni.hideToast()
							uni.navigateTo({
								url: '../orderCollect/orderCollect'
							})
						},500)
					}
				})
			}
		}
	}
</script>

<style>
	.content {
		height: 100%;
		width: 100%;
		overflow-x: hidden;
	}

	.scan_btn {
		width: calc(100% - 48rpx);
		margin-left: 24rpx;
		margin-top: 48rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 12rpx;
		background: #13A684;
		color: #ffffff;
		font-size: 36rpx;
	}
	.scan_btn img{
		width: 44rpx;
		height: 44rpx;
		margin-right: 24rpx;
	}
	.search_box {
		width: calc(100% - 48rpx);
		margin-left: 24rpx;
		margin-top: 24rpx;
		border-radius: 12rpx;
		background: #ffffff;
		height: 128rpx;
	}

	.input_box {
		display: flex;
		background: #eeeeee;
		border-radius: 12rpx;
		width: 500rpx;
		height: 80rpx;
		align-items: center;
	}

	.input_box img {
		width: 32rpx;
		height: 32rpx;
		margin-left: 24rpx;
		margin-right: 24rpx;
	}

	.search_box_search {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: calc(100% - 48rpx);
		margin-left: 24rpx;
		height: 100%;
	}

	.search_btn {
		width: 130rpx;
		height: 80rpx;
		background-color: #13A684;
		color: #ffffff;
		border-radius: 12rpx;
		font-size: 32rpx;
		border: none
	}
	.order_box{
		width: calc(100% - 48rpx);
		margin-left: 24rpx;
		margin-top: 24rpx;
		border-radius: 12rpx;
		background: #ffffff;
		padding-bottom: 1rpx;
	}
	.express_code{
		padding-top: 34rpx;
		margin-left: 24rpx;
		font-size: 28rpx;
		color: #999999;
	}
	.receiver_base_msg_box{
		display: flex;
		margin-top: 34rpx;
		margin-left: 24rpx;
		align-items: center;
	}
	.receiver_base_msg_box img{
		width: 60rpx;
		height: 60rpx;
		margin-right: 12rpx;
	}
	.receiver_name{
		font-size: 32rpx;
		color: #333333;
		line-height: 60rpx;
	}
	.receiver_phone{
		font-size: 32rpx;
		color: #3A9BFF;
		margin-left: 24rpx;
		line-height: 60rpx;
	}
	.receiver_address{
		width: calc(100% - 48rpx);
		margin-left: 24rpx;
		margin-top: 24rpx;
		font-size: 28rpx;
		color: #666666;
		padding-bottom: 12rpx;
	}
	.fenge{
		width: calc(100% - 48rpx);
		height: 2rpx;
		margin-left: 24rpx;
		margin-bottom: 24rpx;
		background-color: #eeeeee;
	}
	.receiver_remark,.agent_fee,.receiver_created_at{
		width: calc(100% - 48rpx);
		margin-left: 24rpx;
		margin-bottom: 24rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
		color: #666666;
	}
	.agent_fee_text{
		color: #13A684;
	}
	.collect_btn{
		position: fixed;
		bottom: 50rpx;
		width: calc(100% - 80rpx);
		left: 40rpx;
		border-radius: 20rpx;
		height: 180rpx;
		background: #13A684;
		color: #ffffff;
		text-align: center;
		line-height: 180rpx;
		font-size: 60rpx;
	}
</style>
